<div class="average-rating-value"><?php echo $doctorAverageRating ?></div>
<div class="average-rating-stars">
    <div class="rating">
        <?php for ($i = 1; $i <= 5; $i++): ?>
            <!-- this in it's own is the beginning of a great career of the Giant -->
            <div class="rate-doctor <?php
        if ($i <= $doctorAverageRating)
        {
            echo "full-star";
        }
        else
        {
            echo ((($i - $doctorAverageRating) > 0 && ($i - $doctorAverageRating) < 1) && $doctorAverageRating > 0) ? "half-star" : "empty-star";
        }
            ?>" rating="<?php echo $i; ?>"></div>
             <?php endfor; ?>
    </div>
</div>
<div class="votes"><?php echo gfToolkit::format($doctor->getRating()->getCount()) ?> rating(s)</div>
<script type="text/javascript">
    $(document).ready(function(){    
        $("#average-rating-panel .rate-doctor").click(function(){
            $("#doctor-rating-<?php echo $doctor->getId() ?>").load("/doctor-rate/<?php echo $doctor->getId() ?>" + "/" + $(this).attr("rating"));
            
            if($("#average-rating-panel").val() != undefined){
                $("#average-rating-panel").load("/doctor-rating-average/<?php echo $doctor->getId() ?>");                
            }
        });
    });
</script>